<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>initTimeDivergence</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script>
$(document).ready(function () {

	// 인터페이스
	var utils = {
		addListener: null,
		remeveListener: null
	};
	
	// 구현
	if (typeof window.addEventListener === 'function') {
		utils.addListener = function (el, type, fn) {
			el.addEventListener(type, fn, false);
			console.log("new browser");
		};
		utils.removeListener = function (el, type, fn) {
			el.removeEventListener(type, fn, false);
		};
	} else if (typeof document.attachEvent === 'function') { // IE
		utils.addListener = function (el, type, fn) {
			el.attachEvent('on' + type, fn);
		};
		utils.removeListener = function (el, type, fn) {
			el.detachEvent('on' + type, fn);
		};
	} else { // 구형 브라우저
		utils.addListener = function (el, type, fn) {
			el['on' + type] = fn; 
		};
		utils.removeListener = function (el, type, fn) {
			el['on' + type] = null; 
		};
	}
	
	utils.addListener(document.getElementById("myButton"), "click", ( function () { alert("Nice to meet you~"); }) );
});
</script>

</head>
    <body>
	    <h3>초기화 시점의 분기</h3>
	    <input type="button" id="myButton" value="Hello"/>
    </body>
</html>